function getServerHost() {
  var host1 = "./json/";
  /* var host2 = "http://10.122.202.211:8080/"; */
  var host2 = "http://wkfw.unisk.cn/api/woqianbao/feedback/";
  return host2;
}
window.alert = function (name) {
  var iframe = document.createElement("IFRAME");
  iframe.style.display = "none";
  iframe.setAttribute("src", 'data:text/plain,');
  document
    .documentElement
    .appendChild(iframe);
  window
    .frames[0]
    .window
    .alert(name);
  iframe
    .parentNode
    .removeChild(iframe);
};
//使用requestAnimationFrame创建动画
(function () {
  var lastTime = 0;
  var vendors = ["webkit", "moz"];
  for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
    window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
    window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || // name has changed in Webkit
    window[vendors[x] + "CancelRequestAnimationFrame"];
  }

  if (!window.requestAnimationFrame) {
    window.requestAnimationFrame = function (callback, element) {
      var currTime = new Date().getTime();
      var timeToCall = Math.max(0, 16.7 - (currTime - lastTime));
      var id = window.setTimeout(function () {
        callback(currTime + timeToCall);
      }, timeToCall);
      lastTime = currTime + timeToCall;
      return id;
    };
  }
  if (!window.cancelAnimationFrame) {
    window.cancelAnimationFrame = function (id) {
      clearTimeout(id);
    };
  }
})();

function preventMove() {
  document
    .addEventListener("touchmove", function (a) {
      a.preventDefault();
    }, {passive: false});
}

function GetRequest() {
  var e = location.href;
  var f = {};
  if (e.indexOf("?") != -1) {
    var g = e.substr(e.indexOf("?") + 1);
    g = g.split("&");
    for (var h = 0; h < g.length; h++) {
      f[g[h].split("=")[0]] = decodeURI(g[h].split("=")[1]);
    }
  }
  return f;
}

function judgePhone() {
  var u = navigator.userAgent;
  if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) { //安卓手机
    return {type: 'Android', val: 0}
    // window.location.href = "mobile/index.html";
  } else if (u.indexOf('iPhone') > -1) { //苹果手机
    // window.location.href = "mobile/index.html";
    return {type: 'ios', val: 1}
  } else if (u.indexOf('Windows Phone') > -1) { //winphone手机
    return {type: 'wPhone', val: 2}
    // window.location.href = "mobile/index.html";
  }
}
//横屏无效
window
  .addEventListener("orientationchange", function () {
    if (0 !== window.orientation) {
      alert('请竖屏浏览');
    } else {}
  }, false);

function checkMobile(str) { //写一个判断函数
  var re = /^1\d{10}$/ //正则表达式
  if (re.test(str)) { //判断字符是否是11位数字
    return true;
  } else {
    return false;
  }
}
//引入animate.css
function closeBar(btnele, parentele) {
  $(btnele)
    .click(function () {
      $(parentele)
        .addClass('slideOutUp')
        .removeClass('slideInDown');
    });
}

function showBar(btnele, parentele) {
  $(btnele)
    .click(function () {
      $(parentele)
        .addClass('slideInDown')
        .removeClass('slideOutUp none');
    });
  $(btnele).off('click');
}

function autoshowBar(parentele) {
  $(parentele)
    .addClass('slideInDown')
    .removeClass('slideOutUp none');

}

function autocloseBar(parentele) {
  $(parentele)
    .addClass('slideOutUp ')
    .removeClass('slideInDown');
}
export {getServerHost, preventMove, GetRequest, checkMobile}
